package dao

import models.Tables._
import play.api.db.slick.{DatabaseConfigProvider, HasDatabaseConfigProvider}
import slick.jdbc.JdbcProfile

import javax.inject.Inject
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future

class CdsDao @Inject()(protected val dbConfigProvider: DatabaseConfigProvider) extends
  HasDatabaseConfigProvider[JdbcProfile] {

  import profile.api._

  type MyRow = CdsRow
  val table = Cds

  def insertAll(rows: Seq[MyRow]): Future[Unit] = {
    db.run(table ++= rows).map(_ => ())
  }

  def deleteAll: Future[Unit] = db.run(table.delete).map(_ => ())

}
